<!--
 * @Author: kangjia kjhangzhou@163.com
 * @Date: 2022-09-25 20:25:25
 * @LastEditors: kangjia
 * @LastEditTime: 2022-10-12 15:55:20
 * @FilePath: \boss-web-h5\pages\coupons\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
	<view>
    <coupons-tabs :list="tabs" :tabType="tabType" styles="width:50%" @change="tabChange" @changeTabType="changeTabType"></coupons-tabs>
<!--    <component :is="tabType"></component>-->
    <coupon v-if="tabType == 'coupon'" />
    <packageCard ref="componentRef" v-if="tabType == 'packageCard'" />
  </view>
</template>

<script>
  import couponsTabs from "../components/uni-tabs/index.vue"
  import coupon from './module/coupon.vue'
  import packageCard from './module/packageCard.vue'
  export default {
    components: {
      couponsTabs,
      coupon,
      packageCard
    },
    props:{

    },
    data() {
      return {
        tabType: uni.getStorageSync('couponsTab') ? uni.getStorageSync('couponsTab') : 'coupon' ,//菜单类型
        tabs:[]
      }
    },
    onLoad(opt) {
    },
    onUnload() {
      uni.removeStorageSync('couponsTab')
    },
    onShow() {
      this.tabs = [
        {key:'coupon',name:this.$t('JLink.coupon.coupon'),icon:"pay"},
        {key:'packageCard',name:this.$t('JLink.packageCard.name'),icon:"edit"},
      ]
    },
    methods: {
      changeTabType(value) {
        this.tabType = value
      },
      tabChange (item) {
        const {key} = item;
        uni.setStorageSync('couponsTab',key)
        this.tabType = key;
        uni.removeStorageSync('packageCardSelect')
        uni.removeStorageSync('packageCardSelChannel')
        // this.$nextTick(()=>{
        //   this.$refs.componentRef.handleMethod()
        // })
      }
    }
  }
</script>

<style lang="less" scope>
@import '@/common/style/main.css';
</style>
